package com.ruoyi.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.platform.annotation.Excel;
import com.ruoyi.platform.core.domain.BaseEntity;
import com.ruoyi.platform.utils.BeanUtils;
import com.ruoyi.platform.utils.spring.SpringUtils;
import com.ruoyi.utils.BaseFileUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.List;

/**
 * 组件对象 tp_module_info
 *
 * @author tp
 * @date 2022-11-02
 */
@ApiModel(value = "组件对象 tp_module_info", description = "tp_module_info业务表")
@TableName("tp_module_info")
public class ModuleInfo extends BaseEntity<ModuleInfo> {
    private static final long serialVersionUID = 1L;

    /**
     * 编号ID
     */
    @ApiModelProperty(value = "${comment}")
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 一级标题
     */
    @Excel(name = "一级标题")
    @ApiModelProperty(value = "一级标题")
    private String title;

    /**
     * 名称
     */
    @Excel(name = "名称")
    @ApiModelProperty(value = "名称")
    private String name;


    /**
     * 文档ID
     *
     */
    private Long documentId;

    @TableField(exist = false)
    private String documentName;

    public String getDocumentName() {
        return documentName;
    }

    public void setDocumentName(String documentName) {
        this.documentName = documentName;
    }

    public Long getDocumentId() {
        return documentId;
    }

    public void setDocumentId(Long documentId) {
        this.documentId = documentId;
    }

    /**
     * 类型
     */
    @Excel(name = "类型")
    @ApiModelProperty(value = "类型")
    private Integer type;

    /**
     * 图片对应的文件ID
     */
    @Excel(name = "图片对应的文件ID")
    @ApiModelProperty(value = "图片对应的文件ID")
    private Long imageId;

    /**
     * 下载地址
     */
    @Excel(name = "下载地址")
    @ApiModelProperty(value = "下载地址")
    private String downloadUrl;

    /**
     * 描述信息
     */
    @Excel(name = "描述信息")
    @ApiModelProperty(value = "描述信息")
    private String description;

    /**
     * 状态(MODULE_STATUS是否可用 1可用 0不可用)
     */
    @Excel(name = "状态(MODULE_STATUS是否可用 1可用 0不可用)")
    @ApiModelProperty(value = "状态(MODULE_STATUS是否可用 1可用 0不可用)")
    private Integer status;

    /**
     * 删除标志（0未删除1已删除）
     */
    @ApiModelProperty(value = "状态(MODULE_STATUS是否可用 1可用 0不可用)")
    private Integer delFlag;

    @ApiModelProperty(value = "上传图片的实际url地址")
    @TableField(exist = false)
    private String realFileUrl;

    @TableField(exist = false)
    private List<ModuleInfo> children;

    public List<ModuleInfo> getChildren() {
        return children;
    }

    public void setChildren(List<ModuleInfo> children) {
        this.children = children;
    }

    public String getRealFileUrl() {
        String realFileUrl = "";
        if (BeanUtils.isNotEmpty(this.imageId)) {
            realFileUrl = SpringUtils.getBean(BaseFileUtils.class).getFileUrlById(imageId.toString());
        }
        return realFileUrl;
    }

    public void setRealFileUrl(String realFileUrl) {
        this.realFileUrl = realFileUrl;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getType() {
        return type;
    }

    public void setImageId(Long imageId) {
        this.imageId = imageId;
    }

    public Long getImageId() {
        return imageId;
    }

    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    public String getDownloadUrl() {
        return downloadUrl;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getStatus() {
        return status;
    }

    public void setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
    }

    public Integer getDelFlag() {
        return delFlag;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("title", getTitle())
                .append("documentId", getDocumentId())
                .append("documentName", getDocumentName())
                .append("name", getName())
                .append("type", getType())
                .append("imageId", getImageId())
                .append("downloadUrl", getDownloadUrl())
                .append("description", getDescription())
                .append("status", getStatus())
                .append("delFlag", getDelFlag())
                .append("createTime", getCreateTime())
                .append("createBy", getCreateBy())
                .append("updateTime", getUpdateTime())
                .append("updateBy", getUpdateBy())
                .toString();
    }
}
